package cn.lovemmd.bms.service.Impl;

import cn.lovemmd.bms.mapper.CheckMapper;
import cn.lovemmd.bms.pojo.Check;
import cn.lovemmd.bms.service.CheckService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class CheckServiceImpl implements CheckService {
    private final CheckMapper checkMapper;

    @Autowired
    public CheckServiceImpl(CheckMapper checkMapper) {
        this.checkMapper = checkMapper;
    }

    @Override
    public Integer addCheck(String tTime, String tWay, String tDetail, String tRemark, BigDecimal tAmount, BigDecimal icbcBalance, BigDecimal abcBalance, BigDecimal bcBalance, BigDecimal wechatBalance, BigDecimal overallBalance) {
        return checkMapper.addCheck(tTime,tWay,tDetail,tRemark,tAmount,icbcBalance,abcBalance,bcBalance,wechatBalance,overallBalance);
    }

    @Override
    public Integer deleteCheck(int tId) {
        return checkMapper.deleteCheck(tId);
    }

    @Override
    public Integer deleteCheckByTimeInterval(String startTime, String endTime) {
        return checkMapper.deleteCheckByTimeInterval(startTime,endTime);
    }

    @Override
    public IPage<Check> selectCheckPageByTime(int pageNum, int pageSize, String time) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPageByTime(page,time);
    }

    @Override
    public IPage<Check> selectCheckPageByWay(int pageNum, int pageSize, String tWay) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPageByWay(page,tWay);
    }

    @Override
    public IPage<Check> selectCheckPageByTimeInterval(int pageNum, int pageSize, String startTime, String endTime) {
       IPage<Check> page = new Page<>(pageNum,pageSize);
       return checkMapper.selectCheckPageByTimeInterval(page,startTime,endTime);
    }

    @Override
    public IPage<Check> selectCheckPageByLessThanAmount(int pageNum, int pageSize, BigDecimal amount) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPageByLessThanAmount(page,amount);
    }

    @Override
    public IPage<Check> selectCheckPageByGreaterThanAmount(int pageNum, int pageSize, BigDecimal amount) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPageByGreaterThanAmount(page,amount);
    }

    @Override
    public IPage<Check> selectCheckPageByAmountRange(int pageNum, int pageSize, BigDecimal minAmount, BigDecimal maxAmount) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPageByAmountRange(page,minAmount,maxAmount);
    }

    @Override
    public BigDecimal getTotalExpenditure() {
        return checkMapper.getTotalExpenditure();
    }

    @Override
    public BigDecimal getGrossIncome() {
        return checkMapper.getGrossIncome();
    }

    @Override
    public IPage<Check> selectCheckPage(int pageNum, int pageSize) {
        IPage<Check> page = new Page<>(pageNum,pageSize);
        return checkMapper.selectCheckPage(page);
    }

    @Override
    public Integer updateCheck(int tId, String tWay, String tDetail, String tRemark, BigDecimal tAmount, BigDecimal icbcBalance, BigDecimal abcBalance, BigDecimal bcBalance, BigDecimal wechatBalance, BigDecimal overallBalance) {
        return checkMapper.updateCheck(tId,tWay,tDetail,tRemark,tAmount,icbcBalance,abcBalance,bcBalance,wechatBalance,overallBalance);
    }
}
